package com.test;

import java.io.UnsupportedEncodingException;

import com.sc.apiConstant.AlgIdConstants;
import com.sc.hsm.HsmCSPApi;
import com.sc.hsm.HsmCSPApiImpl;
import com.sc.hsm.response.domain.SymmetricDecrypt;
import com.sc.hsm.response.domain.SymmetricEncrypt;
import com.sc.hsm.utils.PaddUtils;
import com.sc.utils.ResultObject;
import com.sc.utils.bc.util.encoders.Hex;

public class HsmTest3 {
    public static byte[] publicKey = null;
    public static byte[] publicKey2 = null;
    public static byte[] signData = null;
    public static byte[] encData = null;
    public static byte[] encData2 = null;

    public HsmTest3() {
    }

    public static void main(String[] args) throws UnsupportedEncodingException {
        String s = PwServerUtils.encryptBySMS4_ECB("1234abcd");
        System.out.println(s);
        System.out.println(PwServerUtils.decryptBySMS4_ECB(s));

        long startTime = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            String str = PwServerUtils.encryptBySMS4_ECB("1234abcd");
            PwServerUtils.decryptBySMS4_ECB(str);
        }
        System.out.println("ECB use tiem=" + (System.currentTimeMillis() - startTime));
        System.out.println("----------");

        s = PwServerUtils.encryptBySMS4_CBC("1234abcd", "1234567812345678");
        System.out.println(s);
        System.out.println(PwServerUtils.decryptBySMS4_CBC(s, "1234567812345678"));
        startTime = System.currentTimeMillis();
        for (int i = 0; i < 10000; i++) {
            String str = PwServerUtils.encryptBySMS4_CBC("1234abcd", "1234567812345678");
            PwServerUtils.decryptBySMS4_CBC(str, "1234567812345678");
        }
        System.out.println("CBC use tiem=" + (System.currentTimeMillis() - startTime));

    }

}
